package com.zlm.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 身份认证状态
 * @Author: duyufu
 * @Date: 2019/5/14 11:45
 */
public enum IdNoStatusEnum {

    ID_NO_STATUS_0(0,"未认证"),
    ID_NO_STATUS_1(1,"认证中"),
    ID_NO_STATUS_2(2,"已认证"),
    ID_NO_STATUS_3(3,"认证失败");

    private Integer code;
    private String name;

    private IdNoStatusEnum(Integer code, String name){
        this .code=code;
        this .name=name;
    }

    public static List getIdNoStatusEnum(){
        List list = new ArrayList();
        Map<String,Object> map;
        for(IdNoStatusEnum job:IdNoStatusEnum.values()){
            map= new HashMap<String, Object>();
            map.put("code", job.getCode());
            map.put("name", job.getName());
            list.add(map);
        }
        return list;
    }

    public static String getNameByCode(Integer code){
        for(IdNoStatusEnum job:IdNoStatusEnum.values()){
            if(job.getCode().equals(code)){
                return job.getName();
            }
        }
        return null;
    }

    public static String getIdNoStatusEnumJsonString(){
        StringBuilder builder = new StringBuilder("{");
        for(IdNoStatusEnum job:IdNoStatusEnum.values()){
            builder.append("\""+job.getCode()+"\":\""+ job.getName()+"\",");
        }
        String json=builder.substring(0, builder.length()-1)+"}";
        return json;
    }

    @Override
    public  String toString(){
        return "[code=" + code + ", name=" + name + "]";
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }





}
